<?php

class AdminFoundationsController extends AdminAppController {
	
	public $name = 'Foundations';
	
	public $uses = array('Foundation');
	
	public function index() {
		$this->Foundation->recursive = 0;
		$this->paginate = array (
			'order' => array('Foundation.id' => 'desc')
		);
		$this->set('foundations', $this->paginate());
	}
	
	public function create() {
		if( $this->request->is('post') ) {
			
			$this->Foundation->create();
			if( $this->Foundation->save( $this->request->data ) ) {
				$this->setUserInfo(__d('admin', 'The Foundation has been created.'), 'success');
				$this->redirect(array('action' => 'index'));
			}
			else {
				$this->log('Error creating Foundation: ' . print_r($this->Foundation->validationErrors, true));
				$this->setUserInfo(__d('admin', 'The Foundation could not be saved. Please, try again.'), 'error');
			}
		}
		
		//$this->set('types', $this->Foundation->User->find('list', array('order' => array('User.first_name', 'User.last_name'))));
	
	}
	
}